package com.xiaotu.storage;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.SepratorUtil;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;

import net.sf.json.JSONObject;

/**
 * 
 * 项目名称：Sprider-WebMagic-bak    
 * 类名称：MaoYanSearchMovieStorageProcessor    
 * 类描述：    
 * 创建人：张晓   
 * 创建时间：2020年1月2日 下午3:03:17    
 * @version
 */
@Component("MaoYanMoviePeopleSupplementStorageProcessor")
public class MaoYanMoviePeopleSupplementStorageProcessor extends AHSetStorageProcessor {

	private static final String[] FIELD_ARR = new String[]{
			"dataid",
			"tvname", 
			"sexNames", "sexRates",
			"ageNames","ageRates",
			"eduNames", "eduRates",
			"areaNames", "areaRates",
			"occpName", "occpRates", 
			"labelNames", "labelRates"
			};

    private static final String[] CONVERT_ARR = new String[]{
    		AConverter.STRING_CONVERT,
    		AConverter.STRING_CONVERT,
            AConverter.STRINGARRAY_CONVERT, AConverter.RATEARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, AConverter.RATEARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, AConverter.RATEARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, AConverter.RATEARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, AConverter.RATEARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, AConverter.RATEARRAY_CONVERT, 
            };
    
    

    private static final boolean[] THROW_ARR = new boolean[]{
    		true, 
    		true,
    		true, true, true, true, true, true,
    		true, true, true, true, true, true
            };

    @Override
    protected String getRedisKey(Date date)
    {
    	return "MOVIE_PEOPLE_SUPPLMENT";
    }


    @Override
    public String process(JSONObject target, CacheDataModel cacheData,
            Date date)
    {
        return this.list2CSVLine(ConverterFactory.convert(target, FIELD_ARR, CONVERT_ARR,
                THROW_ARR), SepratorUtil.SEP_PIPE);
    }

    @Override
    public String getDataType()
    {
        return Constants.PageDataType.BASICINFO;
    }

    @Override
    public String getTaskType()
    {
        return Constants.SpiderTaskType.MOVIE_BOXOFFICE;
    }
	
}
